﻿using ATM.BUS;
using ATM.DAO;
using ATM.Entities;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ATMSystem
{
    public partial class frmInsertCard : Form
    {
        public frmInsertCard()
        {
            InitializeComponent();
        }

        private Card card;
        private Account acc;

        public void UpdateCurrentAccount()
        {
            acc = new Account();
            acc = AccountDAO.GetCurrentAccount(card);
        }
        public void UpdateCurrentCard(string cardNo)
        {
            card = new Card();
            card = CardDAO.GetCurrentCard(cardNo);
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            switch (ValidationBUS.ValidateCardID(txtCardID.Text))
            {
                case 1:
                    UpdateCurrentCard(txtCardID.Text);
                    UpdateCurrentAccount();
                    frmInsertPIN frm = new frmInsertPIN(acc,card);
                    frm.ShowDialog();
                    
                    break;
                case 0:
                    txtWarning.Text = "THIS CARD IS BLOCKED !";
                    break;
                case 2:
                    txtWarning.Text = "THIS CARD IS NOT VALID !";
                    break;
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
